﻿using System;
using UnityEngine;


namespace HEFramework
{
    /// <summary>
    ///
    /// 框架中心（初始化入口）
    /// 
    /// ----------------------------------------
    /// 作者 hep
    /// 创建时间：2023-12-12 20:45:49
    /// ----------------------------------------
    /// </summary>
    public class Main : MonoBehaviour
    {
        private void Awake()
        {
            DontDestroyOnLoad(gameObject);
            //游戏帧率设置
            QualitySettings.vSyncCount = Config.APP_VSYNCCOUNT;
            Application.targetFrameRate = Config.APP_FRAMERATE;
            World.Instance.Awake();
        }

        private void Update()
        {
            World.Instance.Update();
        }

        private void LateUpdate()
        {
            World.Instance.LateUpdate();
        }

        private void OnGUI()
        {
            float fps = 1.0f / Time.deltaTime;
            GUILayout.Label(fps.ToString("0"), Config.Fps_Style);
        }

        private void OnApplicationQuit()
        {
            World.Instance.Dispose();
        }

        public static void New()
        {
            World.Instance.Dispose();
            World.Instance.Awake();
        }
    }
}